package com.test.shiver.service.impl;

import com.test.shiver.dao.UserDao;
import com.test.shiver.entity.User;
import com.test.shiver.service.UserService;

import java.util.List;

public class UserServiceImpl implements UserService {

    private UserDao userDao = new UserDao();

    @Override
    public List<User> GetUserList() {
        return userDao.selectAll();
    }

    @Override
    public int removeUserById(int id) {
        return userDao.delete(id);
    }

    @Override
    public User getUserById(int id) {
        return userDao.find(id);
    }

    @Override
    public int addUser(User user) {
        return userDao.insert(user);
    }

    @Override
    public int updateUser(User user) {
        return userDao.update(user);
    }

    public static void main(String[] args) {
        UserDao userDao = new UserDao();
        List<User> userList = userDao.selectAll();
        for (int i = 0; i < userList.size(); i++) {
            System.out.println("userName:"+userList.get(i).username);
        }
    }
}
